package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.CollectCodeEnum;
import com.heima.model.wemedia.dtos.WmMaterialDTO;
import com.heima.model.wemedia.pojos.WmMaterial;
import com.heima.wemedia.service.WmMaterialService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Api(value = "素材管理API",tags = "素材管理API")
@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {
    @Autowired
    WmMaterialService service;

    @PostMapping("/upload_picture")
    public ResponseResult uploadPic(@RequestParam MultipartFile multipartFile){
        return service.uploadPicture(multipartFile);
    }

    @PostMapping("/list")
    public ResponseResult picList(@RequestBody WmMaterialDTO dto){
        return service.picList(dto);
    }

    @GetMapping("/del_picture/{id}")
    public ResponseResult delPic(@PathVariable Integer id){
        return service.delPic(id);
    }

    @GetMapping("collect/{id}")
    public ResponseResult collect(@PathVariable Integer id){
        return service.updateCollect(id, CollectCodeEnum.COLLECT_CODE_ENUM);
    }
    @GetMapping("cancel_collect/{id}")
    public ResponseResult cancelCollect(@PathVariable Integer id){
        return service.updateCollect(id,CollectCodeEnum.CANCEL_COLLECT_CODE_ENUM);
    }
}
